package controller

import (
	"admin/model"
	"common/helper"
	"encoding/json"
	"github.com/valyala/fasthttp"
)

type ReportApiFeeController struct{}

func (this *ReportApiFeeController) ApiFee(ctx *fasthttp.RequestCtx) {
	param := model.ReportApiFeeParam{}
	err := json.Unmarshal(ctx.PostBody(), &param)
	if err != nil {

		helper.RetData(ctx, false, "参数错误")
		return
	}
	param.IsOperator = ctx.QueryArgs().GetUintOrZero("is_operator")
	param.IsBusiness = ctx.QueryArgs().GetUintOrZero("is_business")

	if param.Page < 1 {
		param.Page = 1
	}

	if param.PageSize < 10 || param.PageSize > 3000 {
		helper.RetData(ctx, false, "参数错误")
		return
	}

	s, err := model.ReportApiFeeList(param, ctx)
	if err != nil {
		helper.RetData(ctx, false, err.Error())
		return
	}

	helper.RetData(ctx, true, s)
}

func (this *ReportApiFeeController) Test(ctx *fasthttp.RequestCtx) {
	helper.RetData(ctx, true, "成功")
}
